#!/usr/bin/env python
# encoding: utf-8
'''
@author: luohui
@license: (C) Copyright 2013-2018.
@contact: 254272115@qq.com
@software: personal
@file: maincase.py
@time: 2018/9/29 15:54
@desc:主类MainCase，封闭了unittest框架的setUp和tearDown共用方法
'''
import unittest
from operate.readConfig import ReadConfig
from operate.log import logger
from operate.baseoperate import BaseOperate


class MainCase(unittest.TestCase):
    """
    The base class is for all test case.
    """
    def setUp(self):
        # 测试之前加载app的desired caps
        logger.info('========================Start========================')
        desired_caps = {
            'platformName': ReadConfig.get_data()['platformName'],
            'platformVersion': ReadConfig.get_data()['platformVersion'],
            'deviceName': ReadConfig.get_data()['deviceName'],
            'automationName': ReadConfig.get_data()['automationName'],
            'noReset': ReadConfig.get_data()['noReset'],
            'newCommandTimeout': ReadConfig.get_data()['newCommandTimeout']
            # self.desired_caps['unicodeKeyboard'] = data['unicodeKeyboard']
            # self.desired_caps['resetKeyboard'] = data['resetKeyboard']
            # desired_caps['appPackage'] = data['appPackage']
            # desired_caps['appActivity'] = data['appActivity']
        }
        # 测试之前远程启动app
        self.driver = BaseOperate(ReadConfig.get_data()['baseUrl'], desired_caps)

    def tearDown(self):
        # 测试完毕时关闭app
        logger.info('==========================End==========================')
        self.driver.quit()

if __name__ == '__main__':
    unittest.main()
